Total Complexity | 2 |
Total Lines | 11 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import { lastDayOfMonth, format } from 'date-fns'; |
||
2 | |||
3 | export class MonthDate { |
||
4 | constructor(public readonly year: number, public readonly month: number) {} |
||
5 | |||
6 | getFirstDay(): Date { |
||
7 | return new Date(`${this.year}-${String(this.month).padStart(2, '0')}-01`); |
||
8 | } |
||
9 | |||
10 | getLastDay(): Date { |
||
11 | const localDate = lastDayOfMonth(this.getFirstDay()); |
||
12 | return new Date(format(localDate, 'yyyy-MM-dd')); |
||
13 | } |
||
15 |